package com.geyue.controller;

import com.geyue.common.toolbox.result.Res;
import com.geyue.core.model.Integral;
import com.geyue.core.service.IntegralForService;
import com.geyue.core.service.IntegralService;
import com.geyue.core.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;

/**
 * Created by Lyon on 2017/5/16.
 */
@Controller
@RequestMapping("/integral")
public class IntegralController {

    @Autowired
    private IntegralForService integralForService;
    @Autowired
    private UserService userService;
    @Autowired
    private IntegralService integralService;

    @RequestMapping(value = "/", method = RequestMethod.GET)
    public String list() {
        return "integral/list";
    }

    @RequestMapping(value = "/", method = RequestMethod.POST)
    @ResponseBody
    public Res list(Integer pageSize, Integer pageNum) {
        return integralService.pageList(pageNum,pageSize);
    }


    @RequestMapping(value = "/ok", method = RequestMethod.PUT)
    @ResponseBody
    public Res ok(Integer id) {
        Integral integral = new Integral();
        integral.setId(id);
        integral.setIsOk(1);

        if(integralService.updateNotEmpty(integral) > 0 )
            return Res.success("操作成功!");

        return Res.fail("操作失败");
    }

}
